<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class Process::Status - RDoc Documentation</title>


<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>

<script src="../js/jquery-3.2.0.min.js"></script>

<script src="../js/vue.min.js"></script>
<script src="../js/js.cookie.min.js"></script>

<link href="../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../css/rdoc.css" rel="stylesheet">
<link href="../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../";
  var index_rel_prefix = "../";
  var darkModeCsseHref = "../css/rdoc-dm.css"
  var defaultModeCssHref = "../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0-preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../table_of_contents.html#pages">Pages</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link"><a href="../Object.html">Object</a>
</div>

        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-wait">::wait</a>
    <li ><a href="#method-i-26">#&amp;</a>
    <li ><a href="#method-i-3D-3D">#==</a>
    <li ><a href="#method-i-3E-3E">#&gt;&gt;</a>
    <li ><a href="#method-i-coredump-3F">#coredump?</a>
    <li ><a href="#method-i-exited-3F">#exited?</a>
    <li ><a href="#method-i-exitstatus">#exitstatus</a>
    <li ><a href="#method-i-inspect">#inspect</a>
    <li ><a href="#method-i-pid">#pid</a>
    <li ><a href="#method-i-signaled-3F">#signaled?</a>
    <li ><a href="#method-i-stopped-3F">#stopped?</a>
    <li ><a href="#method-i-stopsig">#stopsig</a>
    <li ><a href="#method-i-success-3F">#success?</a>
    <li ><a href="#method-i-termsig">#termsig</a>
    <li ><a href="#method-i-to_i">#to_i</a>
    <li ><a href="#method-i-to_s">#to_s</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-Process::Status">
    <h1 id="class-Process::Status" class="class">
      class Process::Status
    </h1>

    <section class="description">
    
<p>A <a href="Status.html"><code>Process::Status</code></a> contains information about a system process.</p>

<p>Thread-local variable <code>$?</code> is initially <code>nil</code>. Some methods assign to it a <a href="Status.html"><code>Process::Status</code></a> object that represents a system process (either running or terminated):</p>

<pre class="ruby"><span class="ruby-string">`ruby -e &quot;exit 99&quot;`</span>
<span class="ruby-identifier">stat</span> = <span class="ruby-identifier">$?</span>       <span class="ruby-comment"># =&gt; #&lt;Process::Status: pid 1262862 exit 99&gt;</span>
<span class="ruby-identifier">stat</span>.<span class="ruby-identifier">class</span>      <span class="ruby-comment"># =&gt; Process::Status</span>
<span class="ruby-identifier">stat</span>.<span class="ruby-identifier">to_i</span>       <span class="ruby-comment"># =&gt; 25344</span>
<span class="ruby-identifier">stat</span> <span class="ruby-operator">&gt;&gt;</span> <span class="ruby-value">8</span>       <span class="ruby-comment"># =&gt; 99</span>
<span class="ruby-identifier">stat</span>.<span class="ruby-identifier">stopped?</span>   <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-identifier">stat</span>.<span class="ruby-identifier">exited?</span>    <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-identifier">stat</span>.<span class="ruby-identifier">exitstatus</span> <span class="ruby-comment"># =&gt; 99</span>
</pre>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">





                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-wait" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          Process::Status.wait(pid = -1, flags = 0) &rarr; Process::Status
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Like <a href="../Process.html#method-c-wait"><code>Process.wait</code></a>, but returns a <a href="Status.html"><code>Process::Status</code></a> object (instead of an integer pid or nil); see <a href="../Process.html#method-c-wait"><code>Process.wait</code></a> for the values of <code>pid</code> and <code>flags</code>.</p>

<p>If there are child processes, waits for a child process to exit and returns a <a href="Status.html"><code>Process::Status</code></a> object containing information on that process; sets thread-local variable <code>$?</code>:</p>

<pre class="ruby"><span class="ruby-constant">Process</span>.<span class="ruby-identifier">spawn</span>(<span class="ruby-string">&#39;cat /nop&#39;</span>) <span class="ruby-comment"># =&gt; 1155880</span>
<span class="ruby-constant">Process</span><span class="ruby-operator">::</span><span class="ruby-constant">Status</span>.<span class="ruby-identifier">wait</span>      <span class="ruby-comment"># =&gt; #&lt;Process::Status: pid 1155880 exit 1&gt;</span>
<span class="ruby-identifier">$?</span>                        <span class="ruby-comment"># =&gt; #&lt;Process::Status: pid 1155508 exit 1&gt;</span>
</pre>

<p>If there is no child process, returns an “empty” <a href="Status.html"><code>Process::Status</code></a> object that does not represent an actual process; does not set thread-local variable <code>$?</code>:</p>

<pre class="ruby"><span class="ruby-constant">Process</span><span class="ruby-operator">::</span><span class="ruby-constant">Status</span>.<span class="ruby-identifier">wait</span> <span class="ruby-comment"># =&gt; #&lt;Process::Status: pid -1 exit 0&gt;</span>
<span class="ruby-identifier">$?</span>                   <span class="ruby-comment"># =&gt; #&lt;Process::Status: pid 1155508 exit 1&gt; # Unchanged.</span>
</pre>

<p>May invoke the scheduler hook <a href="../Fiber/Scheduler.html#method-i-process_wait"><code>Fiber::Scheduler#process_wait</code></a>.</p>

<p>Not available on all platforms.</p>

                              <div class="method-source-code" id="wait-source">
            <pre>static VALUE
rb_process_status_waitv(int argc, VALUE *argv, VALUE _)
{
    rb_check_arity(argc, 0, 2);

    rb_pid_t pid = -1;
    int flags = 0;

    if (argc &gt;= 1) {
        pid = NUM2PIDT(argv[0]);
    }

    if (argc &gt;= 2) {
        flags = RB_NUM2INT(argv[1]);
    }

    return rb_process_status_wait(pid, flags);
}</pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-26" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          stat &amp; mask &rarr; integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the logical AND of the value of <a href="Status.html#method-i-to_i"><code>to_i</code></a> with <code>mask</code>:</p>

<pre class="ruby"><span class="ruby-string">`cat /nop`</span>
<span class="ruby-identifier">stat</span> = <span class="ruby-identifier">$?</span>                 <span class="ruby-comment"># =&gt; #&lt;Process::Status: pid 1155508 exit 1&gt;</span>
<span class="ruby-identifier">sprintf</span>(<span class="ruby-string">&#39;%x&#39;</span>, <span class="ruby-identifier">stat</span>.<span class="ruby-identifier">to_i</span>)  <span class="ruby-comment"># =&gt; &quot;100&quot;</span>
<span class="ruby-identifier">stat</span> <span class="ruby-operator">&amp;</span> <span class="ruby-value">0x00</span>               <span class="ruby-comment"># =&gt; 0</span>
</pre>

                              <div class="method-source-code" id="26-source">
            <pre>static VALUE
pst_bitand(VALUE st1, VALUE st2)
{
    int status = PST2INT(st1) &amp; NUM2INT(st2);

    return INT2NUM(status);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-3D-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          stat == other &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns whether the value of <a href="Status.html#method-i-to_i"><code>to_i</code></a> == <code>other</code>:</p>

<pre class="ruby"><span class="ruby-string">`cat /nop`</span>
<span class="ruby-identifier">stat</span> = <span class="ruby-identifier">$?</span>                <span class="ruby-comment"># =&gt; #&lt;Process::Status: pid 1170366 exit 1&gt;</span>
<span class="ruby-identifier">sprintf</span>(<span class="ruby-string">&#39;%x&#39;</span>, <span class="ruby-identifier">stat</span>.<span class="ruby-identifier">to_i</span>) <span class="ruby-comment"># =&gt; &quot;100&quot;</span>
<span class="ruby-identifier">stat</span> <span class="ruby-operator">==</span> <span class="ruby-value">0x100</span>            <span class="ruby-comment"># =&gt; true</span>
</pre>

                              <div class="method-source-code" id="3D-3D-source">
            <pre>static VALUE
pst_equal(VALUE st1, VALUE st2)
{
    if (st1 == st2) return Qtrue;
    return rb_equal(pst_to_i(st1), st2);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-3E-3E" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          stat &gt;&gt; places &rarr; integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the value of <a href="Status.html#method-i-to_i"><code>to_i</code></a>, shifted <code>places</code> to the right:</p>

<pre class="ruby"><span class="ruby-string">`cat /nop`</span>
<span class="ruby-identifier">stat</span> = <span class="ruby-identifier">$?</span>                 <span class="ruby-comment"># =&gt; #&lt;Process::Status: pid 1155508 exit 1&gt;</span>
<span class="ruby-identifier">stat</span>.<span class="ruby-identifier">to_i</span>                 <span class="ruby-comment"># =&gt; 256</span>
<span class="ruby-identifier">stat</span> <span class="ruby-operator">&gt;&gt;</span> <span class="ruby-value">1</span>                 <span class="ruby-comment"># =&gt; 128</span>
<span class="ruby-identifier">stat</span> <span class="ruby-operator">&gt;&gt;</span> <span class="ruby-value">2</span>                 <span class="ruby-comment"># =&gt; 64</span>
</pre>

<p>The behavior is unspecified if <code>places</code> is negative.</p>

                              <div class="method-source-code" id="3E-3E-source">
            <pre>static VALUE
pst_rshift(VALUE st1, VALUE st2)
{
    int status = PST2INT(st1) &gt;&gt; NUM2INT(st2);

    return INT2NUM(status);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-coredump-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          coredump? &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if the process generated a coredump when it terminated, <code>false</code> if not.</p>

<p>Not available on all platforms.</p>

                              <div class="method-source-code" id="coredump-3F-source">
            <pre>static VALUE
pst_wcoredump(VALUE st)
{
#ifdef WCOREDUMP
    int status = PST2INT(st);

    return RBOOL(WCOREDUMP(status));
#else
    return Qfalse;
#endif
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-exited-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          exited? &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if the process exited normally (for example using an <code>exit()</code> call or finishing the program), <code>false</code> if not.</p>

                              <div class="method-source-code" id="exited-3F-source">
            <pre>static VALUE
pst_wifexited(VALUE st)
{
    int status = PST2INT(st);

    return RBOOL(WIFEXITED(status));
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-exitstatus" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          exitstatus &rarr; integer or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the least significant eight bits of the return code of the process if it has exited; <code>nil</code> otherwise:</p>

<pre class="ruby"><span class="ruby-string">`exit 99`</span>
<span class="ruby-identifier">$?</span>.<span class="ruby-identifier">exitstatus</span> <span class="ruby-comment"># =&gt; 99</span>
</pre>

                              <div class="method-source-code" id="exitstatus-source">
            <pre>static VALUE
pst_wexitstatus(VALUE st)
{
    int status = PST2INT(st);

    if (WIFEXITED(status))
        return INT2NUM(WEXITSTATUS(status));
    return Qnil;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-inspect" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          inspect &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a string representation of <code>self</code>:</p>

<pre class="ruby"><span class="ruby-identifier">system</span>(<span class="ruby-string">&quot;false&quot;</span>)
<span class="ruby-identifier">$?</span>.<span class="ruby-identifier">inspect</span> <span class="ruby-comment"># =&gt; &quot;#&lt;Process::Status: pid 1303494 exit 1&gt;&quot;</span>
</pre>

                              <div class="method-source-code" id="inspect-source">
            <pre>static VALUE
pst_inspect(VALUE st)
{
    rb_pid_t pid;
    int status;
    VALUE str;

    pid = pst_pid(st);
    if (!pid) {
        return rb_sprintf(&quot;#&lt;%s: uninitialized&gt;&quot;, rb_class2name(CLASS_OF(st)));
    }
    status = PST2INT(st);

    str = rb_sprintf(&quot;#&lt;%s: &quot;, rb_class2name(CLASS_OF(st)));
    pst_message(str, pid, status);
    rb_str_cat2(str, &quot;&gt;&quot;);
    return str;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-pid" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          pid &rarr; integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the process ID of the process:</p>

<pre class="ruby"><span class="ruby-identifier">system</span>(<span class="ruby-string">&quot;false&quot;</span>)
<span class="ruby-identifier">$?</span>.<span class="ruby-identifier">pid</span> <span class="ruby-comment"># =&gt; 1247002</span>
</pre>

                              <div class="method-source-code" id="pid-source">
            <pre>static VALUE
pst_pid_m(VALUE self)
{
    rb_pid_t pid = pst_pid(self);
    return PIDT2NUM(pid);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-signaled-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          signaled? &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if the process terminated because of an uncaught signal, <code>false</code> otherwise.</p>

                              <div class="method-source-code" id="signaled-3F-source">
            <pre>static VALUE
pst_wifsignaled(VALUE st)
{
    int status = PST2INT(st);

    return RBOOL(WIFSIGNALED(status));
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-stopped-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          stopped? &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if this process is stopped, and if the corresponding wait call had the Process::WUNTRACED flag set, <code>false</code> otherwise.</p>

                              <div class="method-source-code" id="stopped-3F-source">
            <pre>static VALUE
pst_wifstopped(VALUE st)
{
    int status = PST2INT(st);

    return RBOOL(WIFSTOPPED(status));
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-stopsig" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          stopsig &rarr; integer or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the number of the signal that caused the process to stop, or <code>nil</code> if the process is not stopped.</p>

                              <div class="method-source-code" id="stopsig-source">
            <pre>static VALUE
pst_wstopsig(VALUE st)
{
    int status = PST2INT(st);

    if (WIFSTOPPED(status))
        return INT2NUM(WSTOPSIG(status));
    return Qnil;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-success-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          success? &rarr; true, false, or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns:</p>
<ul><li>
<p><code>true</code> if the process has completed successfully and exited.</p>
</li><li>
<p><code>false</code> if the process has completed unsuccessfully and exited.</p>
</li><li>
<p><code>nil</code> if the process has not exited.</p>
</li></ul>

                              <div class="method-source-code" id="success-3F-source">
            <pre>static VALUE
pst_success_p(VALUE st)
{
    int status = PST2INT(st);

    if (!WIFEXITED(status))
        return Qnil;
    return RBOOL(WEXITSTATUS(status) == EXIT_SUCCESS);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-termsig" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          termsig &rarr; integer or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the number of the signal that caused the process to terminate or <code>nil</code> if the process was not terminated by an uncaught signal.</p>

                              <div class="method-source-code" id="termsig-source">
            <pre>static VALUE
pst_wtermsig(VALUE st)
{
    int status = PST2INT(st);

    if (WIFSIGNALED(status))
        return INT2NUM(WTERMSIG(status));
    return Qnil;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-to_i" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          to_i     &rarr; integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the system-dependent integer status of <code>self</code>:</p>

<pre class="ruby"><span class="ruby-string">`cat /nop`</span>
<span class="ruby-identifier">$?</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-comment"># =&gt; 256</span>
</pre>

                              <div class="method-source-code" id="to_i-source">
            <pre>static VALUE
pst_to_i(VALUE self)
{
    int status = pst_status(self);
    return RB_INT2NUM(status);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-to_s" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          to_s &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a string representation of <code>self</code>:</p>

<pre class="ruby"><span class="ruby-string">`cat /nop`</span>
<span class="ruby-identifier">$?</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-comment"># =&gt; &quot;pid 1262141 exit 1&quot;</span>
</pre>

                              <div class="method-source-code" id="to_s-source">
            <pre>static VALUE
pst_to_s(VALUE st)
{
    rb_pid_t pid;
    int status;
    VALUE str;

    pid = pst_pid(st);
    status = PST2INT(st);

    str = rb_str_buf_new(0);
    pst_message(str, pid, status);
    return str;
}</pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>.</p><p><a href="https://jamesbritt.bandcamp.com/">Maximum R+D</a>.  </p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

